<?php 

/**
* 控制器基类
*/
class Controller 
{
	public $data=array();
	//引入模板
	public function display($action='')
	{
		//把数据的键名变成变量名，键值变成变量值
		// extract($this->data);

		$smarty = new Smarty;



		//$smarty->force_compile = true;
		// $smarty->debugging = true;
		$smarty->caching = true;
		$smarty->cache_lifetime = 120;

		// $smarty->left_delimiter = '<xbs'; 
		// $smarty->right_delimiter = 'xbs>'; 

		foreach ($this->data as $k => $v) {
			$smarty->assign($k, $v);
		}

		if(empty($action)){

			$smarty->display(VIEW_PATH.'/'.CONTROLLER_NAME.'/'.ACTION_NAME.'.html');
		}else{

			$smarty->display( VIEW_PATH.'/'.CONTROLLER_NAME.'/'.$action.'.html');
		}






		// if(empty($action)){
		// 	include VIEW_PATH.'/'.CONTROLLER_NAME.'/'.ACTION_NAME.'.html';
		// }else{
		// 	include VIEW_PATH.'/'.CONTROLLER_NAME.'/'.$action.'.html';
		// }
		
	}
	//分配变量
	public function assign($name,$vlues)
	{
		$this->data[$name]=$vlues;
	}
}















 ?>